<!DOCTYPE html>
<html lang="ar">
<head>
	<?php $this->load->helper('url');?>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    
	<!---------------------for autocomplete--------------->
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-1.11.0.min.js');?>" ></script>
	<script type="text/javascript" src="<?php echo base_url('assets/js/jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/jquery-ui.css")?>" rel="stylesheet" type="text/css" />
	<!------------------------------------------------------>
	

<script type="text/javascript" src="<?php echo base_url('assets/js/jquery.tablesorter.min.js');?>" ></script>
	<link href="<?php echo base_url("assets/css/ch_menu.css")?>" rel="stylesheet" type="text/css" />
		<link href="<?php echo base_url("assets/css/table.css")?>" rel="stylesheet" type="text/css" />
			 <link href="<?php echo base_url("assets/css/botton.css")?>" rel="stylesheet" type="text/css" />
	<meta charset="utf-8">
	<title>مرحبا بكم في برنامج تسيير الإقامة الجامعية 3000 سرير</title>
	
</head>

</head>


<?php include_once('header.php');
 ?>
<body>

<?php

	define('LAST_CAPITRE_ID',19);
	define('LAST_ARTICLE_CODE',3);

	 $this->load->library('session');
        $chcl=$this->session->userdata('data_charticle'); //access it
		 $frns=$this->session->userdata('data_fournisseur'); //access it
 
?>
<div class="container">

<?php
$liste_des_fournisseurs= array();
if($results_recherche)
foreach ($results_recherche as $lf){
	array_push($liste_des_fournisseurs, $lf->nom);
	}
	

	?>
	
	

	<form id="recherche_frm" method="post" action="<?php echo base_url("fournisseur_ctr2/find_name/");?>" >
	 <fieldset>
	   <div class="pure-g">
	  <div class="pure-u-1 pure-u-md-1-3">
                <label for="nom">الاسم </label>
				<input id="nom" name="nom" type="text" value="<?php if($results_recherche)echo($results_recherche[0]->nom);?>">
            </div>
		 <button type="submit" id="submit_btn" class="pure-button pure-button-primary">بحث</button>
		   </div>
		  </fieldset>
	</form>
	
<div class = "charticle_browser">
	
<ul class="topmenu" id="css3menu1">
<?php

$mem =0;


for($i = 0; $i < count($chcl); $i++)
{
	if($mem <> $chcl[$i]->id_chapitre)
			{	
				echo('<li class="topmenu"><a style="width:248px;" href="#"><span>
				<img alt="" src="images/sparkle-brown-vertical/info2.png">'. $chcl[$i]->ch_code.' - '.$chcl[$i]->nom_chap.' </span></a>');
				echo('<div style="auto;" class="submenu">');
				echo('<div style="width:100%" class="column">');

			
				echo('<ul><li><a href="'.base_url("fournisseur_ctr2/get_fournisseurs_per_article2/").'/'.$chcl[$i]->id_article.'">
				<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i]->nom_art.'</a></li><br>');

				if(($chcl[$i]->code)== 1 && ($chcl[$i]->id_chapitre == 16))  echo('</ul></div></div></li>'); // patch to fix a unique child
				
			}
			else
			{

				
				echo('<li><a href="'.base_url("fournisseur_ctr2/get_fournisseurs_per_article2/").'/'.$chcl[$i]->id_article.'">
				<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i]->nom_art.'</a></li><br>');

				if($chcl[$i+1]->id_chapitre > $mem) echo('</ul></div></div></li>');
				if(($chcl[$i]->code)== 2 && ($chcl[$i]->id_chapitre == 19))  //if last chapitre et article
				 {

				 
				 	echo('<li><a href="'.base_url("fournisseur_ctr2/get_fournisseurs_per_article2/").'/'.$chcl[$i]->id_article.'">
					<img alt="" src="images/sparkle-brown-vertical/bookmarks.png">'.$chcl[$i]->code.'- '.$chcl[$i+1]->nom_art.'</a></li><br>');

				 	 echo('</ul></div></div></li>');
					//goto end;
					break;
				 }
			}
			    $mem = $chcl[$i]->id_chapitre;	
}	
 ?>
 </ul>
 
</div>

<div class="main_div"> 
<h1><?php echo($titre); ?></h1>
  <div class="CSS_Table_Example" > 
  <table id="myTable" class="tablesorter">
  <thead>
<tr>
   <th>    الهاتف  </th>
  <th> العنوان </th>
   <th>  النشاط </th>
   <th>  المورد </th>
</tr>
</thead>
<?php
$msg=0;
if($results)
foreach($results as $r) 
{

	echo '<tr>
		    <td>'.$r->tel.'</td>
		    <td>'.$r->adresse.'</td>
		   <td>'.$r->titre.'</td>
		  <td> <a href="'.base_url('fournisseur_ctr2/detail/').'/'.$r->id_fournisseur.'/'.$msg.'">'.$r->nom.'</a></td>
		  </tr>'  ;
	
}

  
?>
</table>
 
</div>

</div>

</div>
<div class="pagination_numero">
  <p><?php echo $links;   ?></p>
 </div>
  
<form  style="position: relative; left: 10%;">
<a href="<?php echo base_url("/budget_ctr/load/budget_vew")?>" class="botton">عودة</a>
<!--<a href="<?php echo base_url("/fournisseur_ctr2/ajout")?>" class="botton">ajout</a>-->
<?php
$tab=0;
$errors=0;
  $goupe=$this->session->userdata('user_group'); //access it
if($goupe=="admin"){
echo ('<a href="'. base_url('/fournisseur_ctr2/ajout').'/'.$tab.'/'.$errors.'" class="botton">اضافة</a>');
}
?>
</form> 
</body>
  <script>
 $(document).ready(function() 
    { 
        $("#myTable").tablesorter(); 
    } 
); 
 </script>   
 
 
 <script>
$(function() {
	var liste_fourniss = <?php echo json_encode($liste_des_fournisseurs); ?>;
	$( "#nom" ).autocomplete({source: liste_fourniss});
	} 
); 
</script>
</html>